<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const state = {
            count:10,
            school:'atguigu'
        }
        function mapState(obj){
            let res = {}
            for(let attr in obj){
                // 1. attr count    obj[attr] 'count'
                // 2. attr school   obj[attr] 'school'
                res[attr] = function(){
                    return state[obj[attr]]
                }
            }
            return res
        }

        let r = mapState({
            count:'count',
            school:'school'
        })
        console.log('r: ',r)

        const computed = {
            ...mapState({
                count:'count',
                school:'school'
            })
        }
        console.log('computed',computed)



        // 对象的简写
        let count = 1;
        let school = '尚硅谷'
        let obj1 = {
            count:'count',
            school:'school'
        }
        console.log(obj1)

    </script>
</body>
</html>